a = input()
mx =[0]
if len(a)==4:
    s = [a[0], a[1], a[2], a[3], a[0:2], a[1:3], a[2:4], a[0:3], a[1:4], a]
    for j in range(len(a)):
        n = int(a[j])
        c = 0
        for i in range(1, n+1):
            if n%i == 0:
                c+=1
        if c == 2 and n != 1:
            mx.append(n)
print(max(mx))

